/*
 * @fileOverview: 天迹三期：账单
 * @Author: xiaoyangzhao
 * @Date:   2018-08-23 10:38:22
 * @Last Modified by:   xiaoyangzhao
 * @Last Modified time: 2019-08-06 16:29:28
 */

import request from '@/utils/request'
import { route_origins /* , route_path_get */ } from '@/api/routes'

console.log('route_origins:', route_origins)
const devRoute = route_origins + 'report/'
const currentRoute = devRoute
// request.withCredentials = false

/**
 * [uploadBillConfirm  账单上传确认（通常无特殊处理，由组件内上传）]
 * @param  {Binary} file            [上传文件]
 * @return {Function}               [request]
 */
export function uploadBillConfirm(binary) {
  // const _headerArray = JSON.parse(JSON.stringify(headerArray))
  return request({
    url: currentRoute + '/upload/bill/confirm',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    // transformRequest: request._origin.transformRequest
    data: binary
  })
}
/**
 * [uploadBillConfirm  账单上传确认（通常无特殊处理，由组件内上传）401的返回的时候，点击是，否的时候的返回]
 * @param  {Binary} file            [上传文件]
 * @return {Function}               [request]
 */
export function uploadBillConfirm401(params) {
  return request({
    url: route_origins + 'upload/bill/closeCaseConfirm',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data: params
  })
}

/**
 * [billValidateFailed 首页 模板列表]
 * @param {String} [serialNo]   [确认时返回的serialNo]
 * @return {Function}           [异步接口方法]
 */
export function billValidateFailed(params) {
  params = request.filterPostData(params)
  return request({
    url: route_origins + '/bills/validate-failed',
    method: 'get',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    params
  })
}

/**
 * [userPayment 首页回款]
 * @return {Function}               [request]
 */
export function userPayment(params) {
  return request({
    url: route_origins + 'bills/homepage/data',
    method: 'get',
    params
  })
}

/**
 * [statReportManageGet 报表生成设置get]
 * @param  {Object} params          [案件类型查询条件]
 * @return {Function}               [request]
 */
export function statReportManageGet(params) {
  return request({
    url: currentRoute + 'conf/query',
    method: 'get',
    params
  })
}

/**
 * [uploadedBillList 历史账单查询]
 * @return {Function}               [request]
 */
export function uploadedBillList(params) {
  params = request.filterPostData(params)
  return request({
    url: route_origins + 'bills/billList',
    method: 'get',
    params
  })
}

/**
 * [uploadedBillExport 历史账单导出]
 * @return {Function}               [request]
 */
export function uploadedBillExport(params) {
  params = request.filterPostData(params)
  return request({
    url: route_origins + 'bills/billExport',
    method: 'get',
    params
  })
}

/**
 * [uploadedBillRemove 历史账单删除]
 * @return {Function}               [request]
 */
export function uploadedBillRemove(params) {
  // params = request.filterPostData(params)
  return request({
    url: route_origins + 'bills/remove',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data: params
  })
}

/**
 * [reportViewBillQuery 案件回款情况统计表]
 * @return {Function}               [request]
 */
export function reportViewBillQuery(params) {
  return request({
    url: devRoute + 'bill/query',
    method: 'get',
    params
  })
}
